﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using AutoMapper;

using Happy.Archetype;
using Happy.Application.Domain;
using Happy.Cms.Domain;
using Happy.Cms.Domain.Tags;
using Happy.Cms.Query.Tags;

namespace Happy.Cms.Application.Tags
{
    [ApplicationService]
    public sealed class TagService : AggregateRootService<Tag, TagView, ICmsUnitOfWork>
    {
        protected override Tag CreateAggregate(TagView viewModel)
        {
            var aggregate = new Tag(Guid.NewGuid(), viewModel.Category);

            return Mapper.Map(viewModel, aggregate);
        }

        protected override void UpdateAggregate(Tag aggregate, TagView viewModel)
        {
            Mapper.Map(viewModel, aggregate);
        }
    }
}
